import Vue from "vue";
import VueRouter from "vue-router";
import layout from "../views/layout/index.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/home/dashboard", //首页需要设置路由重定向
  },
  {
    path: "/login",
    name: "Login",
    component: () =>
      import(/* webpackChunkName: "login" */ "../views/login/index.vue"),
  },
  {
    //仪表盘的路由和子路由
    path: "/home",
    name: "home",
    component: layout,
    meta: { title: "首页", icon: "icon-panel", type: "2" },
    children: [
      {
        path: "dashboard",
        name: "dashboard",
        component: () =>
          import(
            /* webpackChunkName: "dashboard" */ "../views/dashboard/index.vue"
          ),
        meta: { title: "仪表盘", type: "2" },
      },
      {
        path: "data",
        name: "dashboarddata",
        component: () =>
          import(/* webpackChunkName: "data" */ "../views/dashboard/data.vue"),
        meta: { title: "设备数据", type: "2" },
      },
    ],
  },
  {
    //设备路由和子路由
    path: "/devive",
    name: "devive",
    component: layout,
    meta: { title: "设备", icon: "icon-luyouqi", type: "2" },
    children: [
      {
        path: "gateway",
        name: "gateway",
        component: () =>
          import(
            /* webpackChunkName: "gateway" */ "../views/devive/gateway.vue"
          ),
          meta: { title: "网关列表", type: "2" },
      },
      {
        path: "sensor",
        name: "sensor",
        component: () =>
          import(/* webpackChunkName: "sensor" */ "../views/devive/sensor.vue"),
          meta: { title: "传感器列表", type: "2" },
      },
      {
        path: "developKit",
        name: "developKit",
        component: () =>
          import(
            /* webpackChunkName: "developKit" */ "../views/devive/developKit.vue"
          ),
          meta: { title: "设备群组", type: "2" },
      },
    ],
  },
  {
    //计费
    path: "/fee",
    name: "fee",
    component: layout,
    meta: { title: "计费", icon: "icon-fyxx", type: "2" },
    redirect: "/fee/accountJ",
    children: [
      {
        path: "accountJ",
        name: "accountJ",
        component: () =>
          import(
            /* webpackChunkName: "accountJ" */ "../views/fee/accountJ.vue"
          ),
          meta: { title: "账号信息", type: "2" },
      },
      {
        path: "recharge",
        name: "recharge",
        component: () =>
          import(
            /* webpackChunkName: "recharge" */ "../views/fee/recharge.vue"
          ),
          meta: { title: "充值记录", type: "2" },
      },
    ],
  },
  {
    //测量类型
    path: "/measurement",
    name: "measurement",
    component: layout,
    meta: { title: "测量类型", icon: "icon-signal", type: "2" },
    redirect: "/measurement/add",
    children: [
      {
        path: "add",
        name: "add",
        component: () =>
          import(/* webpackChunkName: "add" */ "../views/measurement/add.vue"),
          meta: { title: "添加测量类型", type: "2" },

      },
      {
        path: "index",
        name: "index",
        component: () =>
          import(
            /* webpackChunkName: "index" */ "../views/measurement/index.vue"
          ),
          meta: { title: "测量类型列表", type: "2" },
      },
    ],
  },
  {
    //账户
    path: "/account",
    name: "account",
    component: layout,
    meta: { title: "账号", icon: "icon-account", type: "2" },
    redirect: "/account/accountList",
    children: [
      {
        path: "accountList",
        name: "accountList",
        component: () =>
          import(
            /* webpackChunkName: "accountList" */ "../views/account/accountList.vue"
          ),
          meta:{ title: "添加账号", type: "2" },

      },
      {
        path: "addAccount",
        name: "addAccount",
        component: () =>
          import(
            /* webpackChunkName: "addAccount" */ "../views/account/addAccount.vue"
          ),
          meta:{ title: "账号列表", type: "2" },

      },
    ],
  },
  {
    //安全
    path: "/security",
    name: "security",
    component: layout,
    meta: { title: "安全", icon: "icon-anquan", type: "2" },
    redirect: "/security/list",
    children: [
      {
        path: "secretKey",
        name: "secretKey",
        component: () =>
          import(
            /* webpackChunkName: "secretKey" */ "../views/security/secretKey.vue"
          ),
          meta: { title: "添加密钥", type: "2" },

      },
      {
        path: "list",
        name: "list",
        component: () =>
          import(/* webpackChunkName: "list" */ "../views/security/list.vue"),
          meta:{ title: "密钥列表", type: "2" },
      },
    ],
  },
  {
    //登录
    path: "/login",
    name: "login",
        component: () =>
          import(
            /* webpackChunkName: "login" */ "../views/login/index.vue"
          )

      },
 
  {
    path: "*",
    name: "page404",
    component: () =>
      import(/* webpackChunkName: "page404" */ "../views/page404/index.vue"),
  },
];

const router = new VueRouter({
  routes,
});

export default router;
